using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TestCtrl
{
  /// <summary>
  /// Summary description for Form1.
  /// </summary>
  public class Form1 : System.Windows.Forms.Form
  {
    private DSBarCode.BarCodeCtrl BarCode;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Button button2;
    private TextBox textBox1;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;

    public Form1()
    {
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();
      //
      // TODO: Add any constructor code after InitializeComponent call
      //
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose(bool disposing)
    {
      if(disposing)
      {
        if(components != null)
        {
          components.Dispose();
        }
      }
      base.Dispose(disposing);
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
      this.button1 = new System.Windows.Forms.Button();
      this.button2 = new System.Windows.Forms.Button();
      this.textBox1 = new System.Windows.Forms.TextBox();
      this.BarCode = new DSBarCode.BarCodeCtrl();
      this.SuspendLayout();
      // 
      // button1
      // 
      this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
      this.button1.Location = new System.Drawing.Point(9, 176);
      this.button1.Name = "button1";
      this.button1.Size = new System.Drawing.Size(43, 23);
      this.button1.TabIndex = 1;
      this.button1.Text = "Print";
      this.button1.Click += new System.EventHandler(this.button1_Click_1);
      // 
      // button2
      // 
      this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
      this.button2.Location = new System.Drawing.Point(58, 176);
      this.button2.Name = "button2";
      this.button2.Size = new System.Drawing.Size(40, 23);
      this.button2.TabIndex = 2;
      this.button2.Text = "Save";
      this.button2.Click += new System.EventHandler(this.button2_Click);
      // 
      // textBox1
      // 
      this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.textBox1.Location = new System.Drawing.Point(104, 178);
      this.textBox1.Name = "textBox1";
      this.textBox1.Size = new System.Drawing.Size(204, 20);
      this.textBox1.TabIndex = 3;
      this.textBox1.Text = "5654486";
      this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
      // 
      // BarCode
      // 
      this.BarCode.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                  | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.BarCode.BackColor = System.Drawing.Color.White;
      this.BarCode.BarCode = "565448645";
      this.BarCode.BarCodeHeight = 100;
      this.BarCode.BarFooterFont = new System.Drawing.Font("Microsoft Sans Serif", 8F);
      this.BarCode.BarHeaderFont = new System.Drawing.Font("Arial", 22F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(0)));
      this.BarCode.BarHeaderText = "Code 39";
      this.BarCode.BarLeftMargin = 10;
      this.BarCode.BarShowFooter = true;
      this.BarCode.BarShowHeader = true;
      this.BarCode.BarTopMargin = 10;
      this.BarCode.BarVertAlign = DSBarCode.BarCodeCtrl.AlignType.Center;
      this.BarCode.BarWeight = DSBarCode.BarCodeCtrl.BarCodeWeight.Small;
      this.BarCode.BarWideToNarrowRatio = 4;
      this.BarCode.ForeColor = System.Drawing.Color.Black;
      this.BarCode.Location = new System.Drawing.Point(8, 8);
      this.BarCode.Name = "BarCode";
      this.BarCode.Size = new System.Drawing.Size(300, 162);
      this.BarCode.TabIndex = 0;
      // 
      // Form1
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(312, 211);
      this.Controls.Add(this.textBox1);
      this.Controls.Add(this.button2);
      this.Controls.Add(this.button1);
      this.Controls.Add(this.BarCode);
      this.Name = "Form1";
      this.Text = "Form1";
      this.Load += new System.EventHandler(this.Form1_Load);
      this.ResumeLayout(false);
      this.PerformLayout();

    }
    #endregion

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
      Application.Run(new Form1());
    }

    private void Form1_Load(object sender, System.EventArgs e)
    {

    }

    private void button1_Click_1(object sender, System.EventArgs e)
    {
      this.BarCode.Print();
    }

    private void button2_Click(object sender, System.EventArgs e)
    {

      BarCode.SaveImage("c:\\" + BarCode.BarHeaderText + ".png");

    }

    private void textBox1_TextChanged(object sender, EventArgs e)
    {
      BarCode.BarCode = textBox1.Text;

    }
  }
}
